<?php
class IndexAction extends CommonAction {
    public function index(){
		$this->setSeo($this->webConfig);
		$websitesObject = D('Websites');
		
		//获得主要部分的数据
		if(!($websitesCate = F('websites_cate'))){
			$websitesCate = D('WebsitesCate')->getCateTree();
			F('websites_cate', $websitesCate);
		}
		
		$websites = array();
		foreach($websitesCate as $key=>$val){
			if($val['is_best'] == 1){
			$websites[$key] = $val;
			if($val['tree']){
				foreach($val['tree'] as $k=>$v){
					if($v['is_best'] == 1){
						$websites[$key]['tree'][$k]['websites'] = $websitesObject->getList(array('cate_id'=>$v['id'], 'status'=>1), 5);
					}else{
						unset($websites[$key]['tree'][$k]);	
					}
				}	
			}	
			}
		}
		
		$this->assign('websites', $websites);
		$this->assign('websitesCate', $websitesCate);
		
		//推荐目录
		//$recommendWebsites = $websitesObject->getList(array('is_best'=>1, 'status'=>1), 5);	
		//$this->assign('recommendWebsites', $recommendWebsites);
		
		$this->display();
    }
}